package cn.auto.service;

import java.util.HashMap;
import java.util.List;

import cn.auto.common.model.Suite;
import cn.auto.common.model.SuiteCase;
import cn.auto.utility.Status;

public class SuiteService {
	
	Suite suite= new Suite();
	List<Suite> infos=null;
	
	/**
	 * 
	 * @return
	 */
	public HashMap<Object, Object> getCaseSuites(String pid,String sName) {
		infos=suite.searchSuites(pid, sName);
		
		return Status.searchResultCode(infos);
	}
	
	public HashMap<Object, Object> getSuites(String pid) {
		infos=suite.searchSuites(pid);
		return Status.searchResultCode(infos);
	}
	
	public String addSuite(HashMap<String, String> addInfo) {
		boolean isAdd=false;
		String pid = addInfo.get("pid");
		String name = addInfo.get("sname");
		
		isAdd = suite.addSuite(pid, name);
		return Status.booleanResultCode(isAdd);
	}
	
	public String removeSuite(String sid) {
		SuiteCase sc=new SuiteCase();
		Boolean isDel=false;
		List<SuiteCase> sc_info=sc.searchSC(sid);
		//if any case in the module , then not allow delete this module
		if (sc_info.size()==0){
			isDel=suite.delSuite(sid);
		}
		return Status.booleanResultCode(isDel);
		
	}

}
